package com.dinggao.bangda.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dinggao.bangda.R;
import com.dinggao.bangda.data.Bean;
import com.dinggao.bangda.data.BeanAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/4/19.
 */

public class CarownerActivity extends AppCompatActivity {
    @BindView(R.id.back_nearbycar)
    ImageView backNearbycar;
    @BindView(R.id.textView)
    TextView textView;
    @BindView(R.id.distance_text)
    TextView distanceText;
    @BindView(R.id.distance_img)
    ImageView distanceImg;
    @BindView(R.id.distance_nearbycar)
    LinearLayout distanceNearbycar;
    @BindView(R.id.select_text)
    TextView selectText;
    @BindView(R.id.select_img)
    ImageView selectImg;
    @BindView(R.id.select_nearbycar)
    LinearLayout selectNearbycar;
    private BeanAdapter adapter;
    private RecyclerView recyclerView;
    private List<Bean> beenList = new ArrayList<Bean>();
    private MainActivity mainActivity;
    private LinearLayout distance;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nearbycar);
        ButterKnife.bind(this);


        recyclerView = (RecyclerView) findViewById(R.id.data_nearbycar);
        initBean();
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);
        adapter = new BeanAdapter(beenList);
        recyclerView.setAdapter(adapter);
    }

    // RecyclerView内数据填充
    private void initBean() {
        for (int i = 0;i<8;i++){
            Bean beani = new Bean();
            beani.setName_bean((i+1)+"先生");
            beenList.add(beani);
        }

    }

    @OnClick({R.id.back_nearbycar, R.id.textView, R.id.distance_text, R.id.distance_img, R.id.distance_nearbycar, R.id.select_text, R.id.select_img, R.id.select_nearbycar})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_nearbycar:
                //回退到首页面
                this.finish();
                Log.d("car", "back_nearbycar");
                break;
            case R.id.select_text:
                //选择拉人或捎货 、改变颜色字体出现选择列表
                selectImg.setImageDrawable(getResources().getDrawable(R.drawable.moreup));
                distanceText.setTextColor(getResources().getColor(R.color.menu_text));
                distanceImg.setImageDrawable(getResources().getDrawable(R.drawable.more1));
                selectText.setTextColor(getResources().getColor(R.color.menu_click));
                Log.d("car", "select_text");
                break;
            case R.id.distance_text:
                //距离 、改变颜色字体出现选择列表
                distanceText.setTextColor(getResources().getColor(R.color.menu_click));
                distanceImg.setImageDrawable(getResources().getDrawable(R.drawable.moreup));
                selectText.setTextColor(getResources().getColor(R.color.menu_text));
                selectImg.setImageDrawable(getResources().getDrawable(R.drawable.more1));
                Log.d("car", "distance_text");
                break;
            default:
                break;
        }
    }
}
